#pragma once
#include <map>
#include <string>
#include "..\nodes\Node.h"
#include "..\utils\GameMath.h"
#include "..\content\ResManager.h"

namespace ds {

struct TextLine {
	std::string message;
	Vec2 pos;
	Color color;
	bool active;
	TextLine() { 
		message = "" ; pos = Vec2(0,0) ; color = Color(1.0f,1.0f,1.0f,1.0f) ; active = true; 
	}
};

class PlainTextNode  : public Node {

typedef std::map<std::string,TextLine*> TextMap;
typedef std::map<std::string,TextLine*>::iterator TextMapIterator;

public:
	PlainTextNode(const std::string& name,const std::string& fontResourceName);
	virtual ~PlainTextNode();		
	void onCreateDevice();
	void onDestroyDevice();
	void calculateSize(const std::string& reference,Vec2& size);
	// text handling methods	
	void setText(const std::string& reference,const Vec2& pos,char* format,...);
	void setText(const std::string& reference,const Vec2& pos,char* format,va_list args);
	void setText(const std::string& reference,const Vec2& pos,const Color& color,char* format,...);
	void setText(const std::string& reference,const Vec2& pos,const Color& color,char* format,va_list args);
	void removeText(const std::string& reference);
	void hideText(const std::string& reference);
	void showText(const std::string& reference);
	TextLine* getText(const std::string& reference);
	void init() {}
	void loadContent(ResManager& resourceManager) {}
	void prepareRendering() {}
	void draw();

private:
	std::string m_FontName;
	LPD3DXSPRITE m_Sprite;
	TextMap m_TextMap;
};

};
